package cn.com.dealme.service.impl;

import cn.com.dealme.domain.model.User;
import cn.com.dealme.domain.repository.IUserRepository;
import cn.com.dealme.service.UserService;
import cn.com.dealme.service.exception.UserServiceException;

public class UserServiceImpl implements UserService {
	
	private IUserRepository userRepository;

	public User managerLogin(String account, String password) {
		User user = userRepository.findByAccount(account);
		if(null == user) {
			throw UserServiceException.AccountNotFound;
		}
		if(null == password || !password.equals(user.getAccountInfo().getPassword())) {
			throw UserServiceException.PasswordError; 
		}
		return user;
	}

	public IUserRepository getUserRepository() {
		return userRepository;
	}

	public void setUserRepository(IUserRepository userRepository) {
		this.userRepository = userRepository;
	}

	
}
